package com.example.house


import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
import com.alibaba.android.arouter.facade.annotation.Route
import com.example.common.view.view.BaseMvvmActivity
import com.example.house.adapter.HouseStepsAdapter
import com.example.house.databinding.ActivityHouseListBinding
import com.example.house.entity.HouseAddEntity
import com.example.house.entity.Processing

@Route(path = "/house/HouseListActivity")
class HouseListActivity : BaseMvvmActivity<ActivityHouseListBinding>() {
    override fun getLayoutId(): Int = R.layout.activity_house_list
    var houseAddEntity: HouseAddEntity? = null
    val houseStepsAdapter = HouseStepsAdapter()
    override fun initView() {
        super.initView()
        houseAddEntity = intent.getParcelableExtra("houseAddEntity")
        if (houseAddEntity != null) {
            houseAddEntity?.let { item ->
                mDataBinding.applicationArea.text = "${item.applicationArea}㎡"
                mDataBinding.applicationNumber.text = item.applicationNumber
                mDataBinding.contactMethod.text = item.contactMethod
                mDataBinding.contactName.text = item.contactName
                mDataBinding.enterpriseName.text = item.enterpriseName
                mDataBinding.entryPersonnel.text = "${item.entryPersonnel}人"
                mDataBinding.entryTime.text = item.entryTime
                mDataBinding.status.text = item.status
                mDataBinding.time.text= item.entryTime
            }
                    mDataBinding.back.setOnClickListener {
                        finish()
                    }
            mDataBinding.rv.adapter = houseStepsAdapter
            mDataBinding.rv.layoutManager = LinearLayoutManager(this)
            houseStepsAdapter.data.clear()
            houseAddEntity?.processingSteps?.let { houseStepsAdapter.data.addAll(it) }
            houseStepsAdapter.notifyDataSetChanged()
        }else{
            mDataBinding.rv.visibility = android.view.View.GONE
        }
    }
}